package ui.component
{

	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;

	import globals.Global;

	import net.data.EquipItemInfo;

	import util.TextStyle;

	/**
	 * 格子的背景
	 * @author luguobin
	 */
	public class Grid extends Sprite
	{
		private var _frame:Bitmap; //边框
		private var _icon:Bitmap; //道具的图片
		private var _textfield:GameTextField;
		public var clickCallback:Function;
		public var type:uint;
		public var index:uint;

		public static const SIZE:uint = 66;

		public function Grid()
		{
			_frame = new Bitmap();
			this.addChild(_frame);

			_icon = new Bitmap();
			_icon.x = _icon.y = 3;
			this.addChild(_icon);

			_textfield = new GameTextField();
			_textfield.defaultTextFormat = TextStyle.getTextFormat(0x00FF00, 12, true, "right");
			_textfield.width = 68;
			_textfield.y = 47;
			this.addChild(_textfield);
			clear();
		}

		public function update(data:EquipItemInfo):void
		{
			var iconKey:String = "2001";
			_icon.bitmapData = Global.assetsManager.getIconBitmapData(iconKey);
			_frame.bitmapData = Global.assetsManager.getAssetsAsBitmapData("border");
			this.buttonMode = true;
			_textfield.text = "Lv.2";
		}

		public function clear():void
		{
			_icon.bitmapData = Global.assetsManager.getIconBitmapData("2000");
			_frame.bitmapData = Global.assetsManager.getAssetsAsBitmapData("border_blank");
			this.buttonMode = false;
			_textfield.text = '';
		}
	}
}